package br.com.gustavobhz.mvc.logica;

import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.gustavobhz.jdbc.dao.ContatoDAO;
import br.com.gustavobhz.jdbc.modelo.Contato;

public class RemoveContatoLogic implements Logica {
	
	@Override
	public void executa(HttpServletRequest req, HttpServletResponse res)
			throws Exception {
		Contato contato = new Contato();
		ContatoDAO dao = new ContatoDAO();
		
		long id = Long.parseLong(req.getParameter("id"));
		contato.setId(id);
		dao.remove(contato);
		
        RequestDispatcher rd = req.getRequestDispatcher("/lista-contatos-elegante.jsp");
		rd.forward(req, res);
		
	}
}